// https://ac.nowcoder.com/acm/problem/18386
#include <iostream>
#include <algorithm>
using namespace std;
int mp[26];
int kind;

int main()
{
    string s;
    cin >> s;

    int n = s.size();
    int left = 0, right = 0;
    int ret = 1e9;
    while(right < n)
    {
        // 进窗口
        if(mp[s[right] - 'a']++ == 0) kind++;
        while(kind == 26)
        {
            ret = min(ret, right - left + 1);
            // 出窗口
            if(mp[s[left] - 'a']-- == 1) kind--;
            left++;
        }
        right++;
    }
    cout << ret << endl;
}